package xyz.yuzegod.megawalls.classes.normal.arcane;

import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;
import xyz.yuzegod.megawalls.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class SecondSkill extends Skill
{
    public SecondSkill(final Classes classes) {
        super("奥术风暴", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 3.0;
            }
            case 2: {
                return 4.0;
            }
            case 3: {
                return 5.0;
            }
            default: {
                return 3.0;
            }
        }
    }
    
    public int getSpeed(final int level) {
        switch (level) {
            case 1:
            case 2: {
                return 2;
            }
            case 3: {
                return 3;
            }
            default: {
                return 2;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7击杀玩家时,会获得§a" + this.getAttribute(level) + "§7秒的生命恢复II");
            lore.add("   §7和6秒的速度§a" + StringUtils.level(this.getSpeed(level)) + "§7效果。");
            return lore;
        }
        lore.add(" §8▪ §7击杀玩家时,会获得§8" + this.getAttribute(level - 1) + " ➜ §a" + this.getAttribute(level) + "§7秒的生命恢复II");
        lore.add("   §7和6秒的速度§8" + ((this.getSpeed(level - 1) == this.getSpeed(level)) ? StringUtils.level(this.getSpeed(level)) : (StringUtils.level(this.getSpeed(level - 1)) + " ➜ §a" + StringUtils.level(this.getSpeed(level)))) + "§7效果。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill2Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill2Level();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        final Player player = gamePlayer.getPlayer();
        final int level = kitStats.getSkill2Level();
        player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (int)(this.getAttribute(level) * 20.0), 1));
        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 120, this.getSpeed(level) - 1));
        return true;
    }
}
